# -*- coding: utf-8 -*-
##############################################################################
#
#    OpenERP, Open Source Management Solution
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

import time
import datetime
from openerp.report import report_sxw

# report_type = []

class golf_event_registration_report_class(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(golf_event_registration_report_class, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            # 'get_account': self.get_account,
            
        })
        
    # def get_account(self, uid, recordID, context={}):
        # arrRes = []
            
        # print 'golf_event_registration_report_class->get_account:'
        # try:
			
        # except:
            # print '+ error.....'
            # return False
        
        # return arrRes
	
	
report_sxw.report_sxw('report.golf_event_registration_reportname', 'event.registration', 'addons/crea8s_golf_event/report_folder/golf_event_registration_report-asdasd.rml', parser=golf_event_registration_report_class, header=False) 





class golf_event_group_golfer_report_class(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(golf_event_group_golfer_report_class, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            # 'get_account': self.get_account,
            
        })
	
	
report_sxw.report_sxw('report.golf_event_group_golfer_reportname', 'event.registration', 'addons/crea8s_golf_event/report_folder/group_golfer_report-asdasd.rml', parser=golf_event_group_golfer_report_class, header=False) 





class golf_event_sticker_label_report_class(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(golf_event_sticker_label_report_class, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'python_lamda_map': self.python_lamda_map,
            
        })

    def python_lamda_map(self):
        print 'python_lamda_map'
        
        
        def make_incrementor(n):
            return lambda x: x + n
        f = make_incrementor(42)
        print('+ make_incrementor: ' + str(f(0)) )
        
        def cube(x): return x*x*x
        print('+ map, ex01: ' + str(map(cube, range(1, 11))) )
        
        seqA = range(8)
        def add2_1(x, y): return x+y
        print('+ map, ex02: ' + str(map(add2_1, seqA, seqA)) )
        
        seqA = range(8)
        def add2_2(x, y): return (x+y)*2
        print('+ map, ex02.2: ' + str(map(add2_2, seqA, seqA)) )
        
        def f(x): return x % 2 != 0 and x % 3 != 0
        print('+ filter: ' + str(filter(f, range(2, 25))) )
        
        def add3_1(x,y): return x+y
        print('+ reduce01: ' + str(reduce(add3_1, range(1, 11))) ) #,  tổng của các sốtừ1 đến 10
        
        def add3_2(x,y): return (x+y)*2
        print('+ reduce02: ' + str(reduce(add3_2, range(1, 11))) ) #,  tổng của các sốtừ1 đến 10
        
        def sum(seq):
            def add(x,y): return x+y
            return reduce(add, seq, 0)
        print('+ reduce03: ' + str(sum(range(1, 11))) ) #, 
        
        adv01 = reduce(lambda x, y: x * y, map(int, ['2', '3', '4']))  #=> 24 ;
        print('+ advance01: ' + str(adv01))
        
        ids = [1,2,7,9]
        adv02 = dict(map(lambda x: (x,0), ids))
        print('+ advance02: ' + str(adv02))  #?? {1: 0, 2: 0, 9: 0, 7: 0} 
        
        inv_ids = [1,2,7,9]
        adv03 = ','.join(map(str, inv_ids))        # map(str,... => chuyen ve dang string 
        print('+ advance03: ' + str(adv03))  #  ok, result: 1,2,7,9  (string) 
        
        return None
    
report_sxw.report_sxw('report.golf_event_sticker_label_reportname', 'event.registration', 'addons/crea8s_golf_event/report_folder/sticker_label-asdasd.rml', parser=golf_event_sticker_label_report_class, header=False) 



